#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N = 1e5 + 10;
int arr[N];
int res[N];
long long n;
int main()
{
	while (scanf("%lld",&n)!=EOF) {
		memset(arr, 0, sizeof(arr));
		memset(res, 0, sizeof(res));
		for (int i = 1; i <= n; i++) {
			cin >> arr[i];
		}
		int k = 1;
		res[1] = arr[1];
		for (int i = 2; i <= n; i++) {
			int p = 0;
			for (int j = 1; j <= k; j++) {
				if (res[j] >= arr[i]) {
					if (!p) {
						p = j;
					}
					else if (res[p] > res[j]) {
						p = j;
					}
				}
			}
			if (!p) {
				res[++k] = arr[i];
			}
			else {
				res[p] = arr[i];
			}
		}
		cout << k << endl;
	}
	return 0;
}